package com.eg366.cglib;

public class AuthClient {
	public static void main(String[] args) {
		AuthClient c = new AuthClient();
		c.haveNoAuthManager();
		c.haveAuthManager();
	}

	/**
	 * 模拟：登录会员没有权限
	 */
	public void haveNoAuthManager() {
		System.out.println("the loginer's name is not maurice,so have no permits do manager");
		InfoManager noAuthManager = InfoManagerAuthFactory.getInstance(new AuthProxy("maurice1"));
		doCRUD(noAuthManager);
		separatorLine();
	}

	/**
	 * 模拟：登录会员有权限
	 */
	public void haveAuthManager() {
		System.out.println("the loginer's name is eg366,so have permits do manager");
		InfoManager authManager = InfoManagerAuthFactory.getInstance(new AuthProxy("eg366"));
		doCRUD(authManager);
		separatorLine();
	}

	/**
	 * 对Info做增加／更新／删除／查询操作
	 * 
	 * @param manager
	 */
	private void doCRUD(InfoManager manager) {
		manager.create();
		manager.update();
		manager.delete();
		manager.query();
	}

	/**
	 * 加一个分隔行，用于区分
	 */
	private void separatorLine() {
		System.out.println("################################");
	}

}